//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing.Diagram
{
    class Point : IOfficeXmlSerializable
    {
        private PointType type;
        private string modelId;
        private string cxnId;
        private ElementPropertySet prSet;
        private ShapeProperties spPr;
        private TextBody t;
        private OfficeArtExtensionList extLst;
        internal const string xmlName = "pt";
        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read(xmlName))
            {
                this.modelId = c.GetString("modelId");
                this.type = c.GetOptionalEnum("type", PointType.Node);
                cxnId = c.GetOptionalString("cxnId", "0");
                this.prSet = c.ReadOptionalElement<ElementPropertySet>(ElementPropertySet.xmlName);
                this.spPr = c.ReadOptionalElement<ShapeProperties>("spPr");
                this.t = c.ReadOptionalElementAs<TextBody>("t");
                this.extLst = c.ReadOptionalElement<OfficeArtExtensionList>("extLst");
                ;

            }
        }
        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write(xmlName))
            {
                c.SetString("modelId", modelId );
                c.SetOptionalEnum("type", type, PointType.Node);
                c.SetOptionalString("cxnId", cxnId,"0" );
                c.WriteOptionalElement(prSet);
                c.WriteOptionalElement(spPr);
                c.WriteOptionalElementAs(t, "t");
                c.WriteOptionalElement(extLst);
            }
        }
    }
}